/**
 * @this AlertUtil
 *
 * author : srxboys
 * @flow  : 用于 静态语法检查
 *
 *
**/
import React from 'react'
import {} from 'react-native'

import OverlayAlertView from './OverlayAlertView'
import Alert from './component/Alert'

import RXAlert from './component/Alert-ios'

const alert = (title, message, leftTitle, rightTitle, onLeftPress, onRightPress) => {
  let key = null

  const dismiss = () => { OverlayAlertView.hide(key) }

  key = OverlayAlertView.show(
    <Alert
      title={title} message={message}
      leftTitle={leftTitle}
      rightTitle={rightTitle}
      onLeftPress={onLeftPress}
      onRightPress={onRightPress}
      dismiss={dismiss}
    />
  )
}

const rxalert = (config) => {
  let key = null
  const dismiss = () => { OverlayAlertView.hide(key) }
  key = OverlayAlertView.show(
    <RXAlert
      {...config}
      dismiss={dismiss}
    />
  )
}

export default {
  activity: (callback) => {
    alert('', '仅右侧按钮点击有回调', '取消', '确定', () => { }, callback)
  },

  action: (callback) => {
    alert('', '仅左侧按钮点击有回调', '确定', '取消', callback, () => { })
  },

  rxalert: (config = {}) => {
    rxalert(config)
  }
}